<template>
  <div class="payment_status">
    <div class="status_top">
      <van-icon :name="statusIcon" :class="statusClass"/>
      <div>{{statusText}}</div>
    </div>

    <div class="status_text" v-if="isSuccess">
     <span class="red"></span>请耐心等待几秒
    </div>
    <div class="status_text" v-else>系统繁忙, 支付遇到问题, 请您稍后再试!</div>


  </div>
</template>

<script>
export default {
  name: 'payment-status',
  data() {
    return {
      isSuccess: 0,
      overtimer: null,
    }
  },
  created() {
    const that = this
    this.setIsSuccess()
    this.overtimer = setTimeout(()=>{
       //this.$router.push({ path: '/' });//重定向到首页
       //this.$router.go(0)
       //window.location.reload();
      that.$router.push({ path: '/',params: {isRefresh:1}});//重定向到首页
    },3000)
  },
  methods: {
    setIsSuccess(){
      this.isSuccess=this.$router.currentRoute.query.status||0
    },
  },
  computed: {
    statusText() {
      return this.isSuccess ? '定购成功' : '定购失败';
    },
    statusIcon() {
      return this.isSuccess ? 'checked' : 'fail';
    },
    statusClass() {
      return this.isSuccess ? 'success_icon' : 'fail_icon';
    }
  },

  activated() {
    this.isSuccess = this.status === 'success';
  }
};
</script>


<style lang="scss" scopd>
.payment_status {
  padding-top: 30px;
  box-sizing: border-box;
  background-color: #fff;
  text-align: center;
}

.status_top {
  margin-bottom: 15px;
  i {
    margin-bottom: 5px;
  }
  > div {
    font-size: 18px;
  }
}

.status_text {
  color: $font-color-gray;
  margin-bottom: 50px;
}

.status_icon {
  font-size: 80px;
}

i.success_icon {
  @extend .status_icon;
  color: #06bf04;
}

i.fail_icon {
  @extend .status_icon;
  color: #f44;
}
</style>
